<?php

class m131116_071909_oak extends CDbMigration
{
    public function safeUp()
    {
        $sql = 'CREATE TABLE `{{snapshot_preference}}`
                (
                    `id` bigint PRIMARY KEY,
                    `interest_id` tinyint,
                    `gender_id` tinyint,
                    `age_from` tinyint,
                    `age_to` tinyint,
                    `city_id` smallint,
                    `distance` smallint,
                    `created_at` datetime,
                    `updated_at` datetime,

                    CONSTRAINT FOREIGN KEY (`id`) REFERENCES `{{user}}` (`id`),
                    CONSTRAINT FOREIGN KEY (`interest_id`) REFERENCES `{{interest}}` (`id`),
                    CONSTRAINT FOREIGN KEY (`gender_id`) REFERENCES `{{gender}}` (`id`),
                    CONSTRAINT FOREIGN KEY (`city_id`) REFERENCES `{{city}}` (`id`)
                )
                ENGINE=InnoDB DEFAULT CHARSET=utf8;';

        $this->execute($sql);
    }

    public function safeDown()
    {
        return false;
    }
}